/********************************************************************************************************************************* 
 * NaviCore Corporate MIT License 0.1
 * Copyright (c) 2019 GIS Core R&D Department, NavInfo Corp.
 *
 * Permission is hereby granted, free of charge, to any entity within the corporation(Entity) obtaining a copy of this software 
 * and associated documentation files (the "Software"), to deal in the Software without restriction, including without 
 * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
 * and to permit Entities to whom the Software is furnished to do so, subject to the following conditions:
 *
 * 1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. and
 * 2. The above copyright notice, this permission notice and the acknowledgments below shall be displayed in UI or web pages 
 *    if the Software is redistributed in binary form or as web service.
 *
 *    Acknowledgments: "This work uses NaviZeroAndroid provided by GIS Core R&D Department, NavInfo Corp."
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * You may also get a copy of the license at http://navicore.cn/license/NC_MIT_0.1
 **********************************************************************************************************************************/
package com.cennavi.minenavidemo.activity.navi;

import android.app.Fragment;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cennavi.minenavidemo.utils.ScreenUtil;

public abstract class BaseFragment extends Fragment {
	private boolean isStatusBarFited = false;
	protected boolean isFront = false;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return super.onCreateView(inflater, container, savedInstanceState);
	}

	public abstract void initData();

	public abstract void initView();

	/**
	 * 需要适配沉浸式状态栏时才会回调
	 */
	public abstract void fitStatusBar(int statusBarHeight);

	@Override
	public void onResume() {
		super.onResume();
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !isStatusBarFited) {
			//设置Activity沉浸式状态栏
			fitStatusBar(ScreenUtil.getInstance().getStatusBarHeight());
			isStatusBarFited = true;
		}
	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
		if (!isFront)
			return;
	}

	public void setFront(boolean isFront) {
		this.isFront = isFront;
	}
}
